<template>
  <div class="home">
    <el-card>
      <el-form>
        <el-form-item label="用户名">
          <el-input placeholder="请输入用户名" v-model="user.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input placeholder="请输入密码" v-model="user.password"></el-input>
        </el-form-item>
        <el-form-item label="昵称">
          <el-input placeholder="请输入昵称" v-model="user.nickname"></el-input>
        </el-form-item>
        <el-form-item style="text-align: right">
          <el-button type="primary" @click="reg()">注册</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //属性 定义变量
      user:{}
    }
  },
  methods: {//定义方法
    reg(){
      this.axios.post("http://localhost:19000/v1/user/reg",this.qs.stringify(this.user))
          .then((response)=>{
            if (response.data.code==20000){
              this.$message.success("注册成功")
              this.$router.push("/login")//zhangsan
            }else {
              this.$message.error(response.data.message)
            }
          })
    }
  },
  mounted() {//在网页刷新或被加载的时候执行

  }
}
</script>

<style>

</style>
